<style scoped lang="scss">

</style>

<template>
  <div>
    <input v-model=cval >
    <button @click="changeParaentValue">修改父组件信息</button>
  </div>
</template>

<script>
export default {
  name: "Child2",
  props: {
    val : {
      type: String,
    }
  },
  data() {
    return {
      cval: this.val
    }
  },
  methods: {
    changeParaentValue() {
      this.$emit('changeValue', this.cval)
    }
  },
  watch: {
    cval(newVal) {
      console.log('子组件监听到父组件的值变化')
      this.$emit('changeValue', this.cval)
    }
  }
}
</script>
